package com.example.mvc.controller;

import com.example.mvc.bean.BookType;
import com.example.mvc.service.BookService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;

//图书类型列表
@WebServlet("/bookTypeList")
public class BookTypeListServlet extends HttpServlet {
    BookService bookService = new BookService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<BookType> bookTypeList = bookService.getBookTypeList();
        HttpSession session = request.getSession();
        session.setAttribute("bookTypeList",bookTypeList);
        String contextPath = request.getContextPath();
        response.sendRedirect(contextPath+"/admin_booktype.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
